﻿var status = 0;
var choice;
var scrolls = Array(
Array("", 1012011, 0),
Array("", 1012012, 0),
Array("", 1012013, 0),
Array("", 1012014, 0),
Array("", 1012015, 0),
Array("", 1012016, 0),
Array("", 1012017, 0),
Array("", 1012018, 0),
Array("", 1012019, 0),
Array("", 1012020, 0),
Array("", 1012056, 0),
Array("", 1012058, 0),
Array("", 1012059, 0),
Array("", 1012060, 0),
Array("", 1012061, 0),
Array("", 1012070, 0),
Array("", 1012071, 0),
Array("", 1012072, 0),
Array("", 1012073, 0),
Array("", 1012076, 0),
Array("", 1012077, 0),
Array("", 1012078, 0),
Array("", 1012079, 0),
Array("", 1012081, 0),
Array("", 1012084, 0),
Array("", 1012086, 0),
Array("", 1012087, 0),
Array("", 1012088, 0),
Array("", 1012098, 0),
Array("", 1012100, 0),
Array("", 1012101, 0),
Array("", 1012102, 0),
Array("", 1012103, 0),
Array("", 1012132, 0),
Array("", 1012139, 0),
Array("", 1012140, 0),
Array("", 1012141, 0),
Array("", 1012146, 0),
Array("", 1012157, 0),
Array("", 1012158, 0),
Array("", 1012161, 0),
Array("", 1012170, 0),
Array("", 1012171, 0),
Array("", 1012172, 0),
Array("", 1012173, 0),
Array("", 1012174, 0),
Array("", 1012187, 0),
Array("", 1012188, 0),
Array("", 1012189, 0),
Array("", 1012190, 0),
Array("", 1012191, 0),
Array("", 1012201, 0),
Array("", 1012207, 0),
Array("", 1012209, 0),
Array("", 1012210, 0),
Array("", 1012211, 0),
Array("", 1012212, 0),
Array("", 1012213, 0),
Array("", 1012214, 0),
Array("", 1012215, 0),
Array("", 1012216, 0),
Array("", 1012217, 0),
Array("", 1012218, 0),
Array("", 1012219, 0),
Array("", 1012220, 0),
Array("", 1012221, 0),
Array("", 1012222, 0),
Array("", 1012223, 0),
Array("", 1032100, 0),
Array("", 1032101, 0),
Array("", 1032102, 0),
Array("", 1032103, 0),
Array("", 1032104, 0),
Array("", 1032105, 0),
Array("", 1032106, 0),
Array("", 1032107, 0),
Array("", 1032108, 0),
Array("", 1032109, 0),
Array("", 1032110, 0),
Array("", 1032111, 0),
Array("", 1032112, 0),
Array("", 1032113, 0),
Array("", 1032114, 0),
Array("", 1032116, 0),
Array("", 1032121, 0),
Array("", 1032122, 0),
Array("", 1032127, 0),
Array("", 1032128, 0),
Array("", 1032129, 0),
Array("", 1032131, 0),
Array("", 1032132, 0),
Array("", 1032133, 0),
Array("", 1032134, 0),
Array("", 1032136, 0),
Array("", 1032137, 0),
Array("", 1032139, 0),
Array("", 1032140, 0),
Array("", 1032141, 0),
Array("", 1032142, 0),
Array("", 1032143, 0),
Array("", 1032144, 0),
Array("", 1032147, 0),
Array("", 1032148, 0),
Array("", 1032149, 0),
Array("", 1032150, 0),
Array("", 1032151, 0),
Array("", 1032152, 0),
Array("", 1032153, 0),
Array("", 1032154, 0),
Array("", 1032156, 0),
Array("", 1032162, 0),
Array("", 1032163, 0),
Array("", 1032164, 0),
Array("", 1032165, 0),
Array("", 1122000, 0),
Array("", 1122001, 0),
Array("", 1122002, 0),
Array("", 1122003, 0),
Array("", 1122004, 0),
Array("", 1122005, 0),
Array("", 1122006, 0),
Array("", 1122007, 0),
Array("", 1122009, 0),
Array("", 1122010, 0),
Array("", 1122011, 0),
Array("", 1122012, 0),
Array("", 1122013, 0),
Array("", 1122015, 0),
Array("", 1122017, 0),
Array("", 1122018, 0),
Array("", 1122019, 0),
Array("", 1122020, 0),
Array("", 1122021, 0),
Array("", 1122022, 0),
Array("", 1122023, 0),
Array("", 1122024, 0),
Array("", 1122025, 0),
Array("", 1122026, 0),
Array("", 1122027, 0),
Array("", 1122028, 0),
Array("", 1122029, 0),
Array("", 1122030, 0),
Array("", 1122031, 0),
Array("", 1122032, 0),
Array("", 1122033, 0),
Array("", 1122034, 0),
Array("", 1122035, 0),
Array("", 1122036, 0),
Array("", 1122037, 0),
Array("", 1122038, 0),
Array("", 1122058, 0),
Array("", 1122073, 0),
Array("", 1122074, 0),
Array("", 1122075, 0),
Array("", 1122076, 0),
Array("", 1122077, 0),
Array("", 1122080, 0),
Array("", 1122081, 0),
Array("", 1122082, 0),
Array("", 1122083, 0),
Array("", 1122084, 0),
Array("", 1122085, 0),
Array("", 1122086, 0),
Array("", 1122088, 0),
Array("", 1122089, 0),
Array("", 1122090, 0),
Array("", 1122091, 0),
Array("", 1122092, 0),
Array("", 1122093, 0),
Array("", 1122094, 0),
Array("", 1122095, 0),
Array("", 1122096, 0),
Array("", 1122097, 0),
Array("", 1122098, 0),
Array("", 1122099, 0),
Array("", 1122100, 0),
Array("", 1122101, 0),
Array("", 1122102, 0),
Array("", 1122103, 0),
Array("", 1122104, 0),
Array("", 1122105, 0),
Array("", 1122106, 0),
Array("", 1122107, 0),
Array("", 1122108, 0),
Array("", 1122109, 0),
Array("", 1122110, 0),
Array("", 1122111, 0),
Array("", 1122112, 0),
Array("", 1122113, 0),
Array("", 1122114, 0),
Array("", 1122115, 0),
Array("", 1122116, 0),
Array("", 1122117, 0),
Array("", 1122118, 0),
Array("", 1122119, 0),
Array("", 1122120, 0),
Array("", 1122122, 0),
Array("", 1122123, 0),
Array("", 1122124, 0),
Array("", 1122125, 0),
Array("", 1122126, 0),
Array("", 1122128, 0),
Array("", 1122129, 0),
Array("", 1122130, 0),
Array("", 1122131, 0),
Array("", 1122132, 0),
Array("", 1122133, 0),
Array("", 1122134, 0),
Array("", 1122135, 0),
Array("", 1122136, 0),
Array("", 1122137, 0)
);

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) cm.dispose();
    else {
        if (status == 0 && mode == 0) {
            cm.dispose();
            return;
        } else if (status >= 1 && mode == 0) {
            cm.sendOk("好吧，欢迎下次继续光临！.");
            cm.dispose();
            return;
        }
        if (mode == 1) status++;
        else status--;

        if (status == 0) {
            choices = "\r\n兔兔币余额：#r" + cm.getHyPay(1) + "#k个 (#r买后不支持退货哟亲#k)";
            for (var i = 0; i < scrolls.length; i++) {
                choices += "\r\n#L" + i + "##v" + scrolls[i][1] + "##z" + scrolls[i][1] + "#　#d需要#r" + scrolls[i][2] + "#d兔兔币#k#l";
            }
            cm.sendSimpleS("欢迎来到配件1店,你想买我们商店的物品么?请选择吧：." + choices,2);
        } else if (status == 1) {
            cm.sendYesNo("你确定需要购买#v" + scrolls[selection][1] + "##t" + scrolls[selection][1] + "#?");
		choice = selection;
        } else if (status == 2) {
            var money = scrolls[choice][2];
            if (cm.getHyPay(1) < money) {
                cm.sendOk("抱歉，你没足够的兔兔币！");
                cm.dispose();
            } else {
                cm.addHyPay(money);
                cm.gainItem(scrolls[choice][1], 1);
                cm.sendOk("购买成功.");
                cm.dispose();
            }
        }
    }
}